package com.lzw.cpvideoplayer.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lzw.cpvideoplayer.R;
import com.lzw.cpvideoplayer.data.HeadData;
import com.lzw.cpvideoplayer.data.TitleData;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class DetailsFragment extends Fragment {
    private ImageView mCoverImage;
    private TextView mTitle;//标题
    private TextView mDirector;//作者
    private TextView mRegion;//地区
    private TextView mVideoType;//类型
    private TextView mUpdateTime;//更新时间
    private TextView mDescs;//介绍
    private List<TitleData> mData;
    private int position;//第几个视频
    public DetailsFragment(List<TitleData> data, int position) {
        this.position = position;
        mData = data;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_details,container,false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        mCoverImage = view.findViewById(R.id.details_image);
        mTitle = view.findViewById(R.id.details_title);
        mDirector = view.findViewById(R.id.details_director);
        mRegion = view.findViewById(R.id.details_region);
        mVideoType = view.findViewById(R.id.details_video_type);
        mUpdateTime = view.findViewById(R.id.details_update_time);
        mDescs = view.findViewById(R.id.details_descs);
        //给各个控件赋值
        Glide.with(view.getContext()).load(mData.get(position).getCover()).into(mCoverImage);//加载封面图片
        mTitle.setText(mData.get(position).getTitle());
        mDirector.setText("作者: "+mData.get(position).getDirector());
        mRegion.setText("地区: "+mData.get(position).getRegion());
        mVideoType.setText("类型: "+mData.get(position).getVideoType());
        mUpdateTime.setText("更新时间: "+mData.get(position).getUpdateTime());
        mDescs.setText("简介: "+mData.get(position).getDescs());
    }
}
